package com.mls.fivedistrict.server.impl;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.mls.fivedistrict.dao.TaskMapper;
import com.mls.fivedistrict.pojo.TaskReward;
import com.mls.fivedistrict.dao.TaskRewardMapper;
import com.mls.fivedistrict.server.TaskRewardService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Five Team
 * @since 2018-05-23
 */
@Service
public class TaskRewardServiceImpl extends ServiceImpl<TaskRewardMapper, TaskReward> implements TaskRewardService {

    @Autowired
    private TaskRewardMapper taskRewardMapper;

    @Override
    public TaskReward getTaskRewardByTaskID(Long taskId) {
        Wrapper wrapper = Condition.create().eq("task_id", taskId);
        List<TaskReward> taskRewards = taskRewardMapper.selectList(wrapper);
        if (taskRewards != null && taskRewards.size() > 0) {
            return taskRewards.get(0);
        }
        return null;
    }
}
